package com.weichat.tool;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.dao.LessionMapper;
import com.model.Lession;
import com.service.LessionService;


@Component
public class LessionTool {
	@Autowired
	LessionService lessionSerivce;
	@Autowired 
	LessionMapper Ld;
	
	public  boolean judgeLession(int u_id){
		boolean flag=false;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
		SimpleDateFormat df1 = new SimpleDateFormat("HH");
		
		Integer hour=Integer.parseInt(df1.format(new Date()).toString());
		String h1=String.valueOf(hour-1);
		String h2=String.valueOf(hour+1);
		String date=df.format(new Date()).toString()+"%";// new Date()为获取当前系统时间
		if(lessionSerivce.selectByUidAndDate(u_id, h1,h2).size()>0){
			flag=true;
		}
		List<Lession> ls=lessionSerivce.selectByUidAndDate(u_id, h1,h2);
		System.out.println(ls.get(0).getName());
		
		return flag;
	}
	
	
}
